<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>四川蜀讯科技有限公司CMS系统 - 登录</title>
    <link href="/skin/adminhtml/login/css/login.css" rel="stylesheet" />
    <script src="/skin/adminhtml/login/js/jquery.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $(".account").focus(function () {
                $(this).addClass("aconfoucs");
            }).blur(function () {
                $(this).removeClass("aconfoucs");
            });

            $(".password").focus(function () {
                $(this).addClass("paonfocus");
            }).blur(function () {
                $(this).removeClass("paonfocus");
            });

            $(".code").focus(function () {
                $(this).addClass("codonfocus");
            }).blur(function () {
                $(this).removeClass("codonfocus");
            });
        });
    </script>
</head>
<body>
<form action="" id="loginForm">
    <div class="loginbox">
        <div class="logintit">蜀讯科技CMS系统登录</div>
        <div class="loginipt">
            <div class="loginle"><input type="text" class="lginput account"  autocomplete="off" id="username" name="login" value="" maxlength="15" /></div>
            <div class="loginle"><input type="password" class="lginput password " autocomplete="off" id="password" name="password" value="" maxlength="15" /></div>
            <div class="loginle">
                <div class="loginlel"><input type="text" class="lgyinput code " autocomplete="off" id="captcha" maxlength="4" name="captcha" style="text-transform:uppercase"/></div>
                <div class="loginler"><img title="看不清,点击刷新" onClick="get_randfunc(this)" src="<{url path='login/captcha'}>" class="code-img" /></div>
            </div>
            <div class="loginle logmt"><input type="button" value="登 录" class="loginbtn" onClick="checklogin();"  /></div>
            <div class="msg-show" style=" height:21px;line-height:21px;text-align:center; color:#F00; clear:both; display:none">
             <img src="/skin/adminhtml/login/images/error.png" style="width:21px; height:21px;"><span></span>      
       		</div>
        </div>
    </div>
</form>
    <script type="text/javascript">
if(top.location !== self.location) {
  top.location=self.location;
}
function get_randfunc(obj)
{
    var sj = Math.random();
    obj.src=obj.src+'?shuiji=' +sj;
}

document.onkeydown = function(e){
    if(!e) e = window.event;
    if((e.keyCode || e.which) == 13){
        checklogin();
    }
}

function checklogin()
{
    $username = $("#username");
    if($username.val()=="" || $username.val().length <2){
        $username.focus();
        $(".msg-show span").html('用户名不正确!');
        $(".msg-show").show();
		return;
    }
    
    $password = $("#password");
    if($password.val()=="" || $password.val().length <5){
        $password.focus();
        $(".msg-show span").html('密码正确!');
        $(".msg-show").show();
		return;
    }
    
    $captcha = $("#captcha");
    if($captcha.val()=="" || $captcha.val().length != 4){
        $captcha.focus();
        $(".msg-show span").html('验证码不正确!');
        $(".msg-show").show();
		return;
    }
    
    $.ajax({
      type:"post",
      url: "<{url path='login/dologin'}>",
      data: $('#loginForm').serialize(),
      dataType:'json',
      success: function(res){
        if(res.status == 'y'){
            window.location.href = "<{url path='index'}>"
        }else{
            $(".msg-show span").html(res.msg);
            $(".msg-show").show();
            $(".code-img").trigger('click');
            return false
        }
    }});
}
</script>
</body>
</html>
